package com.centriole.service.workflow.entity;

import org.springframework.mail.MailParseException;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 *  额外扩充的实体类： 流程变量 ，在 ProcessServiceImpl中会使用，没有数据库表对应，是一个业务对象
 *  与ProParameter不同
 */
public class FlowVariable {

        private String instanceId;
        private String name;
        private String value;

    public String getInstanceId() {
        return instanceId;
    }

    public void setInstanceId(String instanceId) {
        this.instanceId = instanceId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return "FlowVariable{" +
                "instanceId='" + instanceId + '\'' +
                ", name='" + name + '\'' +
                ", value='" + value + '\'' +
                '}';
    }

    /**
     * 将一个List< FlowVariable > 转换成Map<String,String>
     * @param list
     * @return
     */
    public static Map<String,String> toMap(List<FlowVariable> list){
        if(list == null || list.size() == 0) return null;
        return list.parallelStream().collect(Collectors.toMap( e->e.getName() , e->e.getValue() ));
    }
}
